package com.happypets.listener;

import javax.servlet.http.HttpSessionActivationListener;
import javax.servlet.http.HttpSessionAttributeListener;
import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionEvent;

/**
 * Application Lifecycle Listener implementation class Test
 *
 */
public class Test implements HttpSessionActivationListener, HttpSessionAttributeListener {
	public static int olNum = 0;
	public static int olPeoNum = 0;
	public static int shopSuc = 0;
    /**
     * Default constructor. 
     */
    public Test() {
    	
    }

	/**
     * @see HttpSessionAttributeListener#attributeRemoved(HttpSessionBindingEvent)
     */
    public void attributeRemoved(HttpSessionBindingEvent se)  { 
    	String name = se.getName();
    	if(name.equals("indexFlag")){
    		olNum--;
    	}else if(name.equals("cart")){
    		olPeoNum--;
    	}
    }

	/**
     * @see HttpSessionAttributeListener#attributeAdded(HttpSessionBindingEvent)
     */
    public void attributeAdded(HttpSessionBindingEvent se)  { 
    	
    	String name = se.getName();
    	
    	if(name.equals("indexFlag")){
    		olNum++;
    	}else if(name.equals("cart")){
    		olPeoNum++;
    	}else if(name.equals("shopSuccess")){
    		shopSuc++;
    	}
    	
    	
    	
    	//user 在线会员
    	//indexFlag 访问人数
    	//shopSuccess购物成功
    	
    }

	/**
     * @see HttpSessionActivationListener#sessionDidActivate(HttpSessionEvent)
     */
    public void sessionDidActivate(HttpSessionEvent arg0)  { 
         // TODO Auto-generated method stub
    }

	/**
     * @see HttpSessionActivationListener#sessionWillPassivate(HttpSessionEvent)
     */
    public void sessionWillPassivate(HttpSessionEvent arg0)  { 
         // TODO Auto-generated method stub
    }

	/**
     * @see HttpSessionAttributeListener#attributeReplaced(HttpSessionBindingEvent)
     */
    public void attributeReplaced(HttpSessionBindingEvent arg0)  { 
         // TODO Auto-generated method stub
    }
	
}
